﻿using B.S.Packaged.ErrorCode;
using B.S.Packaged.WebAPI.Write.Applications.Commands.PackagingQualityCommand;
using MediatR;
using Microsoft.AspNetCore.Mvc;

namespace B.S.Packaged.WebAPI.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class PackagingQualityController : ControllerBase
    {
        private readonly IMediator mediator;

        public PackagingQualityController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 成品质检添加
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<object>> AddPackagingQuality(AddPackagingQualityCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 成品质检删除
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> DelPackagingQuality([FromQuery] DelPackagingQualityCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 成品质检修改
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<APIResult<int>> Handle(UpdatePackagingQualityCommand request)
        {
            return await mediator.Send(request);
        }
    }
}
